package com.hiof.servercommunication.background.job;

import com.hiof.servercommunication.RestFulServiceManager;
import com.hiof.servercommunication.exception.NetworkException;
import com.hiof.servercommunication.exception.ServerException;
import com.hiof.servercommunication.receive.beans.Packet;
import com.hiof.servercommunication.receive.beans.TargetInfoPacket;
import com.hiof.settings.user.UserConfiguration;
import com.hiof.utility.Utility;

/**
 * Created by IntelliJ IDEA.
 * User: manish
 * Date: 4/1/12
 * Time: 12:26 PM
 * To change this template use File | Settings | File Templates.
 */
public class NextTargetLocationJob extends AbstractJob {

    @Override
    protected Packet connect2Server() {
        //it is athlete ID because this query is done only by athlete
        int athleteId = UserConfiguration.getInstance().getAttendantId();
        TargetInfoPacket packet = null;
        try {
            packet = RestFulServiceManager.getInstance().getNextTargetLocation(athleteId);
        } catch (NetworkException e) {
            Utility.error(this.getClass().toString(), "Network Exception while fetching next target:" + e.getErrorMessage());
        } catch (ServerException e) {
            Utility.error(this.getClass().toString(), "Server Exception while fetching next target:" + e.getErrorMessage());
        }
        return packet;
    }


}


